<extend name="./public/frame.html"/>
<block name="content">
    <div class="layui-row">
        <div class="layui-col-xs1">
            <div class="layui-btn-group">
                <button class="layui-btn layui-btn-warm" data-type="add">添加权限组</button>
            </div>
        </div>
    </div>
    <table class="layui-table" lay-data="{cellMinWidth: 80, height:'auto', url:'{$url}', page: true,limit: 10, id:'group'}"
           lay-filter="group">
        <thead>
        <tr>
            <th lay-data="{checkbox:true,fixed: true}"></th>
            <th lay-data="{field:'id', width:80, fixed: true, sort: true}">ID</th>
            <th lay-data="{field:'kname', width:120}">权限组代码</th>
            <th lay-data="{field:'kval', width:140}">权限组名</th>
            <th lay-data="{field:'sort', width:120}">排序</th>
            <th lay-data="{fixed:'right', toolbar: '#barDemo', width:100, align:'center'}">操作</th>
        </tr>
        </thead>
    </table>
    <script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-xs layui-btn-normal" lay-event="edit">编辑</a>
    </script>
    <script type="application/javascript">
        layui.use(['table','laytpl','laydate'], function () {
            var table = layui.table
                ;
            //监听工具条
            table.on('tool(group)', function (obj) {
                var data = obj.data; //获得当前行数据
                var layEvent = obj.event; //获得 lay-event 对应的值（也可以是表头的 event 参数对应的值）
                var id = data.id;
                if (layEvent === 'edit') {
                    layer.open({
                        type: 2,
                        title: '编辑'+data.kval,
                        shadeClose: true,
                        shade: 0.8,
                        area: ['100%', '100%'],
                        content: '{:url("/admin/system/editGroup","id=")}' + id, //iframe的url
                    });
                }
            });
            var $ = layui.jquery, active = {
                add: function () {
                    layer.open({
                        type: 2,
                        title: '添加权限组',
                        shadeClose: true,
                        shade: 0.8,
                        area: ['100%', '100%'],
                        content: '{:url("/admin/system/addGroup")}', //iframe的url
                    });
                }
            };
            $('.layui-btn').on('click', function () {
                var type = $(this).data('type');
                active[type] ? active[type].call(this) : '';
            });
        });
    </script>
</block>
